package com.insist.service.impl;

import com.insist.dao.ValidCodeDao;
import com.insist.entity.ValidCode;
import com.insist.service.ValidCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

/**
 * Created by Administrator on 2015/11/6.
 */
@Service
@Transactional
public class ValidCodeServiceImpl implements ValidCodeService {

//    @Autowired
//    private ValidCodeDao validCodeDao;
//
    @Autowired
    private ValidCodeDao validCodeDao;
//
//    @Override
//    public void save(String mobile, String validCode) {
//        ValidCode code = new ValidCode();
//        code.setMobile(mobile);
//        code.setValidCode(validCode);
//        validCodeDao.save(code);
//    }
//
    @Override
    public ValidCode save(String mobile, String validCode){
        ValidCode code = new ValidCode();
        code.setMobile(mobile);
        code.setValidCode(validCode);
        return validCodeDao.save(code);
    }

    @Override
    public ValidCode findLastCode(String mobile) {
        return null;
//        return validCodeDao.getByMobileOrderByIdDesc(mobile,new PageRequest(0,1));
    }
}
